<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title></title>
    <#include "/jeecms_sys/head.html"/>
    <script type="text/javascript">
        var getProductInfo = function() {
            var productCateId = $("#productCateSelect").val();
            var html = "<option value=''>请选择</option>";
            if("" != productCateId) {
                $.get("../product/a_list.do",{"productCateId":productCateId}, function(data) {
                    var dataObject = eval("("+data+")")
                    for(var index in dataObject) {
                        html+="<option value='"+dataObject[index].id+"'>"+dataObject[index].name+"</option>";
                    }
                    $("#productSelect").html(html);
                });
            }else {
                $("#productSelect").html(html);
            }
        };
        function getTableForm() {
            return document.getElementById('tableForm');
        }
        function optDelete() {
            if(Pn.checkedCount('ids')<=0) {
                alert("<@s.m 'error.checkRecord'/>");
                return;
            }
            if(!confirm("<@s.m 'global.confirm.delete'/>")) {
                return;
            }
            var f = getTableForm();
            f.action="o_delete.do";
            f.submit();
        }
        function confirm_group(groupId) {
            if(window.confirm('确定结算？')) {
                var url = "o_settlements.do?id=" + groupId
                $.get(url,"", function(dataStr) {
                    var data = JSON.parse(dataStr);
                    alert(data.message)
                    if(data.status == 1 ) {
                        window.location.href = "v_list.do";
                    }
                });
            }
        }
    </script>
</head>
<body>
<div class="box-positon">
    <!--<div class="rpos"><@s.m "global.position"/>:  <@s.m "product.function"/> - <@s.m "global.list"/></div>-->
    <form class="ropt">
        <input class="add" type="submit" value="<@s.m "global.add"/>" onclick="this.form.action='v_add.do';"/>
    </form>
    <div class="clear"></div>
</div>
<div class="body-box">
    <form action="v_list.do" method="post" style="padding-top:5px;">
        <div>
            商品类别: <@p.select id="productCateSelect" onchange="getProductInfo();" name="productCateId" value=productCateId list=productCates headerKey="" listKey="id" listValue="cateName"  headerValue="cmsDictionary.type.allType"/>
            商品名称: <select id="productSelect" name="productId" ><option value="">请选择</option></select>
            <input class="query" type="submit" value="<@s.m "global.query"/>"/>
        </div>
    </form>
    <form id="tableForm" method="post">
        <input type="hidden" name="pageNo" value="${pageNo!}"/>
        <@p.table value=listGroupBuy;groupBuy,i,has_next><#rt/>
             <@p.column title="<input type='checkbox' onclick='Pn.checkbox(\"ids\",this.checked)'/>" width="20">
                 <input type='checkbox' name='ids' value='${groupBuy.id}'/><#t/>
            </@p.column><#t/>
            <@p.column code="商品名称">${groupBuy.productName!}</@p.column><#t/>
            <@p.column code="商品规格">${groupBuy.productSpecificationName!}</@p.column><#t/>
            <@p.column code="开始时间">${groupBuy.startTime!}</@p.column><#t/>
            <@p.column code="结束时间">${groupBuy.endTime!}</@p.column><#t/>
            <@p.column code="售出量">${groupBuy.saleCount!}</@p.column><#t/>
            <@p.column code="发布状态">
                <#if groupBuy.status ==1>
                    <font color="green">已发布</font>
                <#elseif groupBuy.status==-1>
                    <font color="red">未发布</font>
                <#elseif groupBuy.status==2>
                    <font color="#8b008b">已结算</font>
                </#if>
            </@p.column><#t/>
            <@p.column code="global.operate" align="center">
            <a href="v_to_edit.do?id=${groupBuy.id}" class="pn-opt"><@s.m "global.edit"/></a> <#rt/>
            <#if groupBuy.status ==1>
                <a href="o_update_status.do?id=${groupBuy.id}&status=-1" class="pn-opt">取消发布</a><#rt/>
            <#elseif groupBuy.status ==-1>
                <a href="o_update_status.do?id=${groupBuy.id}&status=1" class="pn-opt">发布</a><#rt/>
            </#if>|
            <a href="../indexPublish/v_add.do?relationId=${groupBuy.id!}&from=2" class="pn-opt">首页发布</a><#rt/>

            <#if groupBuy.status !=2>
                |<a href="javascript:void(0)" class="pn-opt" onclick="confirm_group(${groupBuy.id!})">拼单确认</a>
            </#if>
            |
			<a href="o_search_orders.do?id=${groupBuy.id!}" class="pn-opt">查询订单</a>
            </@p.column><#t/>

        </@p.table>
<div><input class="del-button" type="button" value="<@s.m "global.delete"/>" onclick="optDelete();"/></div>
    </form>
</div>
<#include "/common/alert_message.html"/>
</body>
</html>